///////////////////////////////////////////////
//-- Author: bacth
//-- Created date: 9:20 AM 5/30/2008
//-- Description: hightlight textbox on page
///////////////////////////////////////////////


function input_focus(e)
{	
	if (ie)
	{
		e = event;
		e = e.srcElement;
	}
	else
	{
		e = e.target;
	}
	e.style.border = 'solid 1px #ffa07a';
}
function input_blur(e)
{
	if (ie)
	{
		e = event;
		e = e.srcElement;
	}
	else
	{
		e = e.target;
	}
	e.style.border = 'solid 1px #d0d0d0';
}
function input_init()
{
	var input, inputs = document.getElementsByTagName('input');
	for (var i=0; i<inputs.length; i++)
	{
		input = inputs[i];
		if (input.type.toLowerCase() == 'text')
		{
			ie ? input.attachEvent('onfocus', input_focus) : input.addEventListener('focus', input_focus, false);
			ie ? input.attachEvent('onblur', input_blur) : input.addEventListener('blur', input_blur, false);
			input.style.border = 'solid 1px #d0d0d0';
		} else if (input.type.toLowerCase() == 'checkbox')
			input.style.border = 'none';
	}
	inputs = document.getElementsByTagName('textarea');
	for (var i=0; i<inputs.length; i++)
	{
		input = inputs[i];
		ie ? input.attachEvent('onfocus', input_focus) : input.addEventListener('focus', input_focus, false);
		ie ? input.attachEvent('onblur', input_blur) : input.addEventListener('blur', input_blur, false);
		input.style.border = 'solid 1px #d0d0d0';
	}
	
	// ajax, bacth
	if (typeof(Sys) != 'undefined')
	{
		Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(global_BeginRequestHandler);
		Sys.WebForms.PageRequestManager.getInstance().add_endRequest(global_EndRequestHandler);
	}
}

function trapEnterKey(e, id)
{
	if (!e) e = window.event;
	
	if (e && e.keyCode == 13)
	{
		document.getElementById(id).click();
		return false;
	}
	return true;
}
ie ? window.attachEvent('onload', input_init) : window.addEventListener('load', input_init, false);




function global_BeginRequestHandler(sender, args)
{
	var bgFilter = document.getElementById("bgFilter");
	if (bgFilter)
	{
		bgFilter.style.height = document.getElementById('maintable').offsetHeight + 'px';
		bgFilter.style.display = 'block';
	}
	
	var loading = document.getElementById("imgloading");
	if (loading)
	{
		var top = (window.screen.availHeight - loading.offsetHeight)/2 - 100;
		var left = (document.documentElement.offsetWidth - loading.offsetWidth)/2;
		left = document.body.scrollLeft;
		top = document.body.scrollTop;
		loading.style.display = 'block';
		loading.style.top = top + 'px';
		loading.style.left = left + 'px';
	}
	
	hideAllDropDown();
}
function global_EndRequestHandler(sender, args)
{
	var bgFilter = document.getElementById("bgFilter");
	if (bgFilter)
	{
		bgFilter.style.display = 'none';
	}
	
	var loading = document.getElementById("imgloading");
	if (loading)
	{
		loading.style.display = 'none';
	}
	showAllDropDown();
}